#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
long long a1, a2, b1, b2, c1, c2, d1, d2;

/*
【a1,a2】,【b1,b2】能凑多少种数字k
*/

int equal_K(int k, int a1, int a2, int b1, int b2) {
  if (k < a1 + b1 || k > a2 + b2)
    return 0;
  k -= a1 + b1;
  a2 -= a1;
  b2 -= b1;
  a1 = 0;
  b1 = 0;
  int M = min(a2, b2) + 1;
  if (k <= M - 1)
    return k + 1;
  else if (k > a2 + b2 + 1 - M)
    return (a2 + b2 - k + 1);
  else
    return M;
}

int dayu_K(int k, int a1, int a2, int b1, int b2) {
  if (k < a1 + b1 || k > a2 + b2)
    return 0;
  k -= a1 + b1;
  a2 -= a1;
  b2 -= b1;
  a1 = 0;
  b1 = 0;
  int M = min(a2, b2) + 1;
  int sum = (1 + M) * M - M + ((a2 + b2 + 1) - (2 * M - 1)) * M;
  // cout << sum;

  if (k <= M - 1)
    return sum - (1 + k + 1) * (k + 1) / 2;
  else if (k <= a2 + b2 + 1 - M) {
    int t = k - (M - 1);
    return sum - (1 + M) * M / 2 - t * M;
  } else {
    int t = a2 + b2 - k;
    return (1 + t) * t / 2;
  }
}
// 新增函数：计算满足 a + b + c > d 的组合数
long long count_condition(int a1, int a2, int b1, int b2, int c1, int c2,
                          int d1, int d2) {
  // 计算 a + b + c 的最小值和最大值
  int min_sum = a1 + b1 + c1;
  int max_sum = a2 + b2 + c2;

  // 计算满足 a + b + c > d 的组合数
  long long cnt = 0;
  for (int d = d1; d <= d2; d++) {
    if (min_sum > d) {
      cnt += (a2 - a1 + 1) * (b2 - b1 + 1) * (c2 - c1 + 1);
    } else if (max_sum > d) {
      int sum_min = max(min_sum, d + 1);
      int sum_max = max_sum;
      cnt += count_triple(a1, a2, b1, b2, c1, c2, sum_min, sum_max);
    }
  }
  return cnt % MOD;
}

// 新增函数：计算满足 sum_min <= a + b + c <= sum_max 的组合数
long long count_triple(int a1, int a2, int b1, int b2, int c1, int c2,
                       int sum_min, int sum_max) {
  long long cnt = 0;
  for (int a = a1; a <= a2; a++) {
    int b_min = max(b1, sum_min - a - c2);
    int b_max = min(b2, sum_max - a - c1);
    if (b_min > b_max)
      continue;

    int c_min = max(c1, sum_min - a - b_max);
    int c_max = min(c2, sum_max - a - b_min);
    if (c_min > c_max)
      continue;

    cnt += (b_max - b_min + 1) * (c_max - c_min + 1);
  }
  return cnt % MOD;
}

// 修改 paichu 函数
int paichu(int a1, int a2, int b1, int b2, int c1, int c2, int d1, int d2) {
  return count_condition(a1, a2, b1, b2, c1, c2, d1, d2);
}

int main() {
  // for (int i = 0; i <= 18; i++) {
  //   cout << equal_K(i, 0, 5, 0, 13) << endl;
  // }
  // cout << endl;
  // for(int i=0;i<=7;i++){
  //    cout << dayu_K(i, 0, 5, 0, 2)<<endl;
  // }

  cin >> a1 >> a2 >> b1 >> b2 >> c1 >> c2 >> d1 >> d2;

  int aa = a2 - a1 + 1;
  int bb = b2 - b1 + 1;
  int cc = c2 - c1 + 1;
  int dd = d2 - d1 + 1;
  long long ans = (aa * bb * cc * dd) % MOD;
  //

  ans = (ans + 4ll * MOD - paichu(a1, a2, b1, b2, c1, c2, d1, d2) -
         paichu(a1, a2, c1, c2, b1, b2, d1, d2) -
         paichu(a1, a2, d1, d2, b1, b2, c1, c2) -
         paichu(b1, b2, c1, c2, a1, a2, d1, d2) -
         paichu(c1, c2, d1, d2, a1, a2, b1, b2)) %
        MOD;
  cout << ans;
  return 0;
}